package com.zkaler.commons.utils.generate;

import java.util.UUID;

/**
 * Created by khiker on 2016/7/7.
 */
public class UUIDGenerater {
    /**
     * 随机生成UUID
     * @return
     */
    public static String getUUID() {
        UUID uuid = UUID.randomUUID();
        return uuid.toString();
    }
    /**
     * 随机生成UUID,去除中划线
     * @return
     */
    public static String getShortUUID() {
        return getUUID().replace("-", "");
    }

    /**
     * 随机生成UUID，并转换为大写
     * @return
     */
    public static String getUpperUUID(){
        return getUUID().toUpperCase();
    }

    /**
     * 随机生成UUID,去除中划线，并转换为大写
     * @return
     */
    public static String getUpperShortUUID(){
        return getUUID().toUpperCase();
    }

    /**
     * 根据字符串生成固定UUID
     * @param name
     * @return
     */
    public static String getUUID(String name){
        UUID uuid=UUID.nameUUIDFromBytes(name.getBytes());
        String str = uuid.toString();
        return str.replace("-", "");
    }

    /**
     * 根据字符串生成固定UUID,并转换为大写
     * @param name
     * @return
     */
    public static String getUpperUUID(String name){
        return getUUID(name).toUpperCase();
    }
}
